//https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=23281&ru=/exam/oj/ta&qru=/ta/coding-interviews/question-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D13
// 双栈实现队列；

#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <queue>

using namespace std;

#include <exception>
class Solution {
  public:
    //目前并不是线程安全的。
    void push(int node) {
        stackPush.push(node);
    }

    int pop() {
        if (stackPop.empty()&&stackPush.empty()){
            // 剖出异常；
            return INT_MIN;
        }
        if (!stackPop.empty()) {
            int rt_val =  stackPop.top();
            stackPop.pop();
            return rt_val;
        } 

        //判断保证栈1不是空的，并且栈2是空的，直接push栈1的元素。否则直接返回栈2的元素
        if (stackPop.empty()) {
            while (!stackPush.empty()) {
                stackPop.push(stackPush.top());
                stackPush.pop();
            }
        } 
        int rt_val =  stackPop.top();
        stackPop.pop();
        return rt_val;
    }
  private:
    stack<int> stackPush;
    stack<int> stackPop;
};